#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool isPrime(int n1) {
    if(n1<=1) return false;
    for(int i=2;i*i<=n1;i++){
        if(n1%i==0) return false;}
    return true;}

int main(){
    string s;
    getline(cin,s);

    vector<string>words;
    string word;
    for(char c:s){
        if(c==' '){
            words.push_back(word);
            word.clear();
        }else{
            word+=c;
        }
    }
    words.push_back(word);

    if(words.size()!=3){
        cout<<"Wrong input"<<endl;
        return 0;
    }

    int n=0;
    for (string word:words){
        if(word=="one")n+=1;
        else if(word=="two")n+=2;
        else if(word=="three")n+=3;
        else if(word=="four")n+=4;
        else if(word=="five")n+=5;
        else if(word=="six")n+=6;
        else if(word=="seven")n+=7;
        else if(word=="eight")n+=8;
        else if(word=="nine")n+=9;
        else {
            cout<<"Wrong input"<<endl;
            return 0;
        }
    }

    if(n<100 || n>999){
        cout<<"Wrong input"<<endl;
        return 0;
    }

    int nearestPrime=n;
    while(!isPrime(nearestPrime)) {
        nearestPrime++;
    }

    cout<<nearestPrime<<endl;

    return 0;
}